package edu.rakovic.elearning.pages;

import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.annotations.Inject;

import edu.rakovic.elearning.enums.Role;
import edu.rakovic.elearning.interfaces.User;
import edu.rakovic.elearning.service.Users;

public class UserProfile {
	
	@SessionState
	private User user;

	private boolean userExists;
	
	public User getUser() {
		return user;
	}
	
	Object onActivate() {
		if (!userExists) return Login.class;
		return null;
	}
	@Inject
	private Users users;
	//required for user edit
	@Property
	private User userEdit;
	
	private String exclude;

	private String userName = "";

	public void onActivate(String userName) {
		userEdit = users.retreiveSingleUser(userName);
		System.out.println(userEdit.getUserName());
		this.userName = userName;
	}
	
	public String onPassivate() {
		return userName;
	}

}
